package com.file.manage.infrastructure.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.file.manage.infrastructure.base.dao.impl.BaseDaoImpl;
import com.file.manage.infrastructure.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;
import java.util.List;

public class BaseServiceImpl<M extends BaseDaoImpl,T> implements BaseService<T> {

    @Autowired
    protected M baseDao;

    @Override
    public Boolean save(T entity) {
        return baseDao.save(entity);
    }

    @Override
    public Boolean saveBatch(Collection<T> entityList) {
        return baseDao.saveBatch(entityList);
    }

    @Override
    public Boolean updateById(T entity) {
        return baseDao.updateById(entity);
    }


    @Override
    public Boolean updateBatch(Collection<T> entityList) {
        return baseDao.updateBatchById(entityList);
    }

    @Override
    public Boolean removeByIds(List<String> ids) {
        return baseDao.removeByIds(ids);
    }

    @Override
    public Boolean removeById(String id) {
        return baseDao.removeById(id);
    }

    @Override
    public List<T> list(Wrapper<T> wrapper) {
        return baseDao.list(wrapper);
    }

    @Override
    public Page<T> page(Page<T> page) {
        return (Page<T>) baseDao.page(page);
    }

    @Override
    public Page<T> page(Page<T> page, Wrapper<T> wrapper) {
        return (Page) baseDao.page(page, wrapper);
    }

    @Override
    public T selectById(String id) {
        return (T) baseDao.getById(id);
    }

    @Override
    public List<T> listByIds(Collection<String> ids) {
        return baseDao.listByIds(ids);
    }
}
